//
// Created by miaomiaole on 2023/5/23.
//

#include "array_test.h"


bool Intger::operator==(const int &a) const {
    return false;
}

void array_equal() {
    Intger a = {1, 4};
    Intger b = {2, 5};

    const array<Intger, 4> array_left = {a, b};
    const array<Intger, 4> array_right = {a, b};

    const array<Intger, 4> &array_left_ref = array_left;
    const array<Intger, 4> &array_left_right = array_right;


    //    cout << std::boolalpha << " " << (array_left == array_right) << endl;

}

atomic<int> atomic_ = atomic(19);

Intger a = {1, 4};

atomic<Intger> atomic_intger = atomic(a);

void rvalue_test() {
    int &&a = 10;

    // 编译器类型转换  &&a to &a
    int &a_ref = a;

    int &&a_move_ref = move(a);

    cout << "rvalue_test a_ref " << a_ref << endl;

    cout << "rvalue_test is a " << a << endl;

    cout << "rvalue_test is a_move_ref " << a_move_ref << endl;


    cout << "rvalue_test a_ref " << a_ref << endl;
    cout << "rvalue_test a " << a << endl;

    cout << "===========================" << endl;

    string str = "test rvalue";

    string &&str_ref = std::move(str);

    cout << "str is " << str << endl;
    cout << "str_ref is " << str_ref << endl;
}

Intger &&getIntger(int &a) {
    return {a, a + a};
}

Intger &&getIntger(int &&a) {
    // 右值引用
    return {a, a * a};
}


void divide(int &&a, int &&b) noexcept(false) {
    throw "b is zero !";
    cout << "result c is " << a / b << endl;
};



// pair 使用
void void_make_pair() {
    // 无参初始化
    pair<int, Intger> int_float_pair;
    cout << "int_float_pair first : " << int_float_pair.first << " int_float_pair second :  " << int_float_pair.second.a
         << endl;
    pair<int, int> int_int_pair(1, 3);


    auto tuple = make_tuple(10, 2, 3, 4, "string");


}

